package tests;

import common.Utils;
import org.openqa.selenium.By;

public class ListPage extends Utils {
    public static String url = "http://8.137.19.140:9090/blog_list.html";
    public ListPage() {
        super(url);
    }

    /*
    * 博客列表页 —— 三个模块 ：菜单模块、用户信息模块、博客列表模块
    * */

    //检查博客列表模块是否正确(检查标题、时间、内容、查看全文)
    public void checkBlogList(){
        //检查博客标题
        String titleText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > div.title")).getText();
        //检查博客时间
        String timeText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > div.date")).getText();
        //检查博客内容
        String contentText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > div.desc")).getText();
        //检查博客查看全文按钮
        String actualText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > a")).getText();

        String expectText = "查看全文>>";
//        String expectText = "查看全文";
        //校验查看全文按钮
        //需要使用断言功能必须手动开启 IDEA 中的断言功能
        assert actualText.equals(expectText);
        //校验标题，时间，内容不能为空
        assert !titleText.isEmpty();
        assert !timeText.isEmpty();
        assert !contentText.isEmpty();

        driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > a")).click();
        //此时跳转到博客详情页(一定是有效的)
        DetailUrl = driver.getCurrentUrl();
    }
}
